﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using RFIDSystem.Controllers;
using RFIDSystem.IServices;
using RFIDSystem.Model;
using RFIDSystem.Model.Models;

namespace RFIDSystem.Api.Controllers
{
    [Route("api/[controller]/[action]")]
    [ApiController]
    [Authorize(Permissions.Name)]
    public class InspectionRecordController : BaseApiController
    {
         private readonly IInspectionRecordServices  _inspectionRecordServices;

        public InspectionRecordController(IInspectionRecordServices inspectionRecordServices)
        {
            _inspectionRecordServices = inspectionRecordServices;
        }
        [AllowAnonymous]
        [HttpGet]
        public async Task<MessageModel< List<InspectionRecordViewModel>>> GetInspectionRecords(DateTime dateTime)
        {
            var rs = await _inspectionRecordServices.GetInspectionRecords(dateTime);
            return new MessageModel<List<InspectionRecordViewModel>>
            {
                msg = "获取成功！",
                response = rs
            };
        }

        [HttpDelete]
        public async Task<MessageModel<bool>> DelRFID(string id)
        {
            var rs = await _inspectionRecordServices.DelInspectionRecord(id);
            return new MessageModel<bool>()
            {
                msg = "获取成功！",
                response = rs
            };
        }
    }
}
